home *** CD-ROM | disk | FTP | other *** search
- Path: vnetnews.value.net!usenet
- From: Adonis Ioannou <adonis@value.net>
- Newsgroups: comp.lang.c
- Subject: Large Number Arithmetic
- Date: 27 Feb 1996 05:49:40 GMT
- Organization: Value Net Internetwork Services Inc.
- Message-ID: <4gu61k$52@vnetnews.value.net>
- NNTP-Posting-Host: k103.value.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.2 (Windows; U; 16bit)
-
- Your help will be greatly appreciated...
-
- I am trying to create a simple calculator, which supports + - / * %, using the
- following input from the command line:-
-
- nnn + nnn where nnn is an integer up to 40 digits long.
-
- The output should also be of the same format(no scientific notations)
-
- I have tried to read the values using
-
- scanf("%Lf", &x) where x is a long double(so that I can store these
- large numbers),
- but after I enter more than 20 digits, I start to lose some accuracy.
-
- I also tried to read the input into character arrays, and then convert the string
- using _atold(), but had the same problem. Can anyone give me any clues or suggestions?
-
- I am using VisualC++ 1.52, under WIN95.
-
- Here is an example of what I mean:-
-
- #include <stdio.h>
- #include <stdlib.h>
-
- void main(void)
- {
- long double x;
-
- scanf("%Lf", &x);
- printf("%Lf", x);
- }
-
- If I enter 12345678901234567890 I get the same result.
- If I enter 123456789012345678901 I get 123456789012345678904
-
- Thanks
-
-